<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.3.1.js"></script>

    <script type="application/javascript">
        //-------------1:对象类型-----------
        //键必须是字符串。值可以是任何类型
        /*
        var jsonStr ={"username":"baoqiang","password":"123"};   //Java Bean
        alert(jsonStr.username);

        var jsonStr2 = {"user":{"username":"baoqiang2","password":"123"}};
        alert(jsonStr2.user.password);

        var jsonStr3= {"user1":{"username":"baoqiang2","password":"123"},
                        "user2":{"username":"bingbing","password":"456"}};
        alert(jsonStr3.user.password);
        alert(jsonStr3.user2.username);
        */
        //-------------2:数组类型-----------  Java中集合
        var jsonArray1 = [{"username":"baoqiang1","password":"123"},
            {"username":"baoqiang2","password":"123"},
            {"username":"baoqiang3","password":"123"}];
        alert(jsonArray1[1].username);


        var jsonArray2 = {  //Map<String,List<String>>
            "baobao":[
                {"name":"小双","age":18,"addr":"扬州"},
                {"name":"建宁","age":18,"addr":"北京海淀"},
                {"name":"龙儿","age":38,"addr":"岛国"},
                {"name":"阿珂","age":17,"addr":"台湾"}
            ]
        }
        alert(jsonArray2.baobao[2].addr);

        var jsonArray3 = {
            "baobao":[
                {"name":"小双","age":18,"addr":"扬州"},
                {"name":"建宁","age":18,"addr":"北京海淀"},
                {"name":"龙儿","age":38,"addr":"岛国"},
                {"name":"阿珂","age":17,"addr":"台湾"}
            ],
            "haohao":[
                {"name":"楠楠","age":23,"addr":"北京"},
                {"name":"倩倩","age":18,"addr":"上海"}
            ]
        }
        alert(jsonArray3.haohao[0].addr);

    </script>
</head>
<body>

</body>
</html>